//
//  API.swift
//  TXiOSDemoApp
//
//  Created by xicheng on 16/11/21.
//  Copyright © 2016年 xicheng. All rights reserved.
//

import UIKit

class API {
  
  static func demoDetail(WithId id:String,AndSuccess successBlock:@escaping ((DemoServerModel)->Void) ,AndOnFinish finishBlock:((NetworkTask)->Bool)? ,AndError errorBlock:((DemoServerModel?,NetworkError)->Void)?){
    let task = AFNetworkTask(url: "/demo/details", method: HttpMethod.POST)
    task.addParameter(key: "demoId", value: id)
    task.debugTag = #function
    task.responceDelegate = BusiProxyHandler<DemoServerModel>.init(success:successBlock,error:errorBlock,onfinish:finishBlock)
    NetworkHelper.shareInstance.addTask(task)
  }
  
  static func demoList(WithPageIndex pageIndex:String,AndPageSize pageSize:String ,AndError errorBlock:((DemoPageListServerModel?,NetworkError)->Void)?,AndOnFinish finishBlock:((NetworkTask)->Bool)? , AndSuccess successBlock:@escaping ((DemoPageListServerModel)->Void)){
    let task = AFNetworkTask(url: "/demo/list", method: HttpMethod.POST)
    task.addParameter(key: "pageIndex", value: pageIndex)
    task.addParameter(key: "pageSize", value: pageSize)
    task.needDelayFlag = true
    task.interf = 3
    task.debugTag = #function
    task.responceDelegate = BusiProxyHandler<DemoPageListServerModel>.init(success:successBlock,error:errorBlock,onfinish:finishBlock)
    NetworkHelper.shareInstance.addTask(task)
  }
  
  
}
